"""
from threading import Event

e = Event() 创建线程event对象
e.wait([timeout])  阻塞等待e被set
e.set()   设置e, 使wait结束阻塞
e.clear() 使e回到未被设置状态
e.is_set() 查看当前e是否被设置
"""
from threading import Thread, Event

s = None
e = Event()  # 实例化

print("说对口令免死!")

def fun():
    print("扬子鳄前来拜山头.")
    global s
    s = "床前明夜光"
    e.set()  # 设置e, 操作完共享资源, 使wait结束阻塞.


s = Thread(target=fun)
s.start()
s.join()


e.wait()  # 阻塞等待e被set, 必须等待子线程执行完,或者传参设置阻塞等待时间
if s == "床前明夜光":
    print("床下鞋两双.")
else:
    print("打死他...")



